#! /bin/sh

# This script may be used to launch one of several
# processes of *LAM* MPI job in debug mode. 
#
# This script is designed to work with LAM MPI only.
# Usage: 
#    instead of running "mpirun ... -np xx my_job"
#    run the following: "mpirun ... -np xx lamdebug1 y my_job"
#    where y is the WORLD rank of process to be
#    debugged.
# Notes: this script was created based on info
#    from http://www.lam-mpi.org/faq/category6.php3
#    Consult that page if you have some problems debugging!

rank=$1
shift

if [ "$LAMRANK" = "$rank" ] 
then
  # use this line to launch debug using clewn
  xterm -T "Debugging process $LAMRANK of $LAMWORLD ..." -e clewn -ga \""$*"\"

  # use this line to launch debug using pure gdb
  #xterm -T "Debugging process $LAMRANK of $LAMWORLD ..." -e gdb "$*"
else
  ./$*
fi
